package com.eccloud.controller;

import com.eccloud.service.HelloRemote;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;

/**
 * Created by yunfeng.wang on 2019/3/26.
 */
@RestController
@RequestMapping("ClientTwo")
public class ConsumerController {
    @Autowired
    private HelloRemote helloRemote;
    @Autowired
    private RestTemplate restTemplate;

    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String index(@RequestParam("name") String name) {
        System.out.println("我是消费者");
        return helloRemote.hello(name);
    }

    @RequestMapping("/template/{name}")
    public String template(@PathVariable("name") String name) {
        System.out.println("我是消费者");
        return restTemplate.getForObject("http://service-client-one/ClientOne/hello?name="+name, String.class);
    }

}
